﻿/*
 * @author: wizardc
 */

using Dou.UI;
using UnityEditor;
using UnityEngine;

namespace DouEditor.UI
{
    [CustomEditor(typeof(CircleImage), true)]
    [CanEditMultipleObjects]
    public class CircleImageEditor : DImageEditor
    {
        [MenuItem("GameObject/DouUI/CircleImage", false, 10)]
        private static void CreateUI(MenuCommand menuCommand)
        {
            var go = UIEditorUtil.CreateUIElement("CircleImage");
            var img = go.AddComponent<CircleImage>();
            img.sprite = null;
            img.color = Color.white;
            img.raycastTarget = false;
            UIEditorUtil.PlaceUIElementRoot(go, menuCommand);
        }

        public override void OnInspectorGUI()
        {
            var image = (CircleImage) target;
            using (new GUILayout.VerticalScope())
            {
                image.segmentCount = EditorGUILayout.IntSlider(new GUIContent("圆形线段条数"), image.segmentCount, 1, 100);
                image.fillPercent = EditorGUILayout.Slider(new GUIContent("填充百分比"), image.fillPercent, 0f, 1f);
                image.overrideRaycast = EditorGUILayout.Toggle(new GUIContent("使用圆形检测点击", "注意图形被拉伸或压扁为椭圆时该检测会异常"), image.overrideRaycast);
            }
            base.OnInspectorGUI();
        }
    }
}
